home *** CD-ROM | disk | FTP | other *** search
AMOS Source Code | 1996-01-26 | 3.2 KB | 95 lines |
- ' ********************************************************
- ' *** ***
- ' *** Clip Bob Procedure ***
- ' *** ***
- ' *** by ***
- ' *** ***
- ' *** Joseph Bolin ***
- ' *** ***
- ' ********************************************************
-
- Screen Open 0,320,200,4,Lowres
- Flash Off
- Palette $0,$FFF,$80,$800
- Paper 2 : Pen 1 : Curs Off
- Cls 2 : Ink 0 : Bar 0,0 To 15,15
- Get Bob 1,0,0 To 64,64
- Cls 0
- Ink 3
- Bar 0,88 To 319,Screen Height-1
- Paste Bob 0,0,1
- Locate 2,4 : Print "Orig."
- Paste Bob 0,100,1
- Paper 3 : Locate 2,21 : Print "Copy"
- Paper 0 : Locate 0,9 : Centre "Press a key"
- Wait Key
- Pen 0 : Locate 0,9 : Centre " "
- _CLIPBOB[1,16,16,47,47,0]
- _CLIPBOB[1,6,6,15,15,1]
- Paste Bob 128,100,1
- Paper 3 : Locate 17,21 : Print "Masked"
-
- Procedure _CLIPBOB[_BOB,_XSTART,_YSTART,_XEND,_YEND,_MASK]
-
- ' Inputs: _BOB =Bob to make/erase mask on; To mask an icon, use a minus value
- ' _XPOS,_YPOS=Coordinates of upper-left of section to mask
- ' _XEND,_YEND=Corrdinates of lower-right of section to mask
- ' _MASK =Flag:0=Make section transparent, 1=Make section opaque
- '
- ' Output: Make a section of a bob or icon either transparent or opaque
-
-
- If _BOB>=0 Then SBASE=Sprite Base(_BOB) : MBASE=Sprite Base(-_BOB)
- If _BOB<0 Then SBASE=Icon Base(-_BOB) : MBASE=Icon Base(_BOB)
- If SBASE=0 and _BOB>=0 Then Error 68
- If SBASE=0 and _BOB<0 Then Error 74
- If MBASE<0 and _BOB>=0 Then Make Mask _BOB : MBASE=0
- If MBASE<0 and _BOB<0 Then Make Icon Mask -_BOB : MBASE=0
- If MBASE=0 and _BOB>=0 Then Paste Bob -999,-999,_BOB : MBASE=Sprite Base(-_BOB)
- If MBASE=0 and _BOB<0 Then Paste Icon -999,-999,-_BOB : MBASE=Icon Base(_BOB)
- SWIDTH=Deek(SBASE)*2
- SHEIGHT=Deek(SBASE+2)
- CH:
- If _XSTART<0 Then _XSTART=0
- If _XEND<_XSTART Then Swap _XEND,_XSTART : Goto CH
- CH2:
- If _YSTART<0 Then _YSTART=0
- If _YEND<_YSTART Then Swap _YEND,_YSTART : Goto CH2
- If _XSTART>=SWIDTH*8 Then _XSTART=SWIDTH*8-1
- If _XEND>=SWIDTH*8 Then _XEND=SWIDTH*8-1
- If _YSTART>=SHEIGHT Then _YSTART=SHEIGHT-1
- If _YEND>=SHEIGHT Then _YEND=SHEIGHT-1
- LEFT=(_XSTART+7)/8 : RIGHT=(_XEND+1)/8
- TP=_YSTART : BOTTOM=_YEND
- If RIGHT<=LEFT or BOTTOM=TP Then Goto LFT
- For Y=TP To BOTTOM
- AD=MBASE+4+Y*SWIDTH+LEFT
- For X=1 To RIGHT-LEFT
- If _MASK=0 Then Poke AD,0 Else Poke AD,255
- Inc AD
- Next
- Next
- LFT:
- LBIT=_XSTART and 7
- If LBIT=0 Then Goto RGT
- BT=256
- For B=1 To LBIT
- BT=BT/2
- Next
- Dec BT : AD=MBASE+4+TP*SWIDTH+LEFT-1
- For Y=0 To BOTTOM-TP
- If _MASK=0 Then Poke AD,Peek(AD) and 255-BT : Else Poke AD,Peek(AD) or BT
- Add AD,SWIDTH
- Next
- RGT:
- RBIT=_XEND and 7 : If RBIT=7 or RIGHT<=LEFT Then Pop Proc
- BT=256
- For B=0 To RBIT
- BT=BT/2
- Next
- BT=256-BT : AD=MBASE+4+TP*SWIDTH+RIGHT
- For Y=0 To BOTTOM-TP
- If _MASK=0 Then Poke AD,Peek(AD) and 255-BT : Else Poke AD,Peek(AD) or BT
- Add AD,SWIDTH
- Next
- End Proc